#ifndef _TEST_APP
#define _TEST_APP

//#define USE_IR // Uncomment this to use infra red instead of RGB cam...

#include "ofMain.h"
#include "ofxOpenNI.h"
#include "ofxVectorMath.h"
#include "ParticleManager.h"
#include "crImagePlus.h"
#include "ofxOsc.h"
#include "colorpanel.h"

#define HOST "10.100.9.1"
#define PORT 1234

#define KINSCALE 1.6


#define MODE_PLAY 0
#define MODE_MOVE 1
#define MODE_ZOOM 2
#define MODE_ROT 3
#define MODE_ZOOM2PT 4
#define MODE_VOICE 5

#define MAX_USERS 4


class testApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();
	
		void keyPressed  (int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);

		void	setupRecording(string _filename = "");
		void	setupPlayback(string _filename);
		string	generateFileName();
		void sendOSC(int id);
		void checkGesture();

		bool isLive, isTracking, isRecording, isCloud, isCPBkgnd, isMasking;
		unsigned char * tmpGrayHandPixels;

		ofxOpenNIContext	recordContext, playContext;
		ofxDepthGenerator	recordDepth, playDepth;
#ifdef USE_IR
		ofxIRGenerator		recordImage, playImage;
#else
		ofxImageGenerator	recordImage, playImage; 
#endif
		ofxUserGenerator	recordUser, playUser;
		ofxOpenNIRecorder	oniRecorder;
		
		void				drawMasks();
		int					pointCloudRotationY;
		int					num_player;

		float rotationSpeed, rotationAngle, zoom,  zoom2pt;
		int mode;

		ofPoint Lhand, Rhand, Neck, Head, Hip;
		ofPoint Lhand_old, Rhand_old, tr_amount, axis;

		int touched_point;

		bool far_hands, bDetected;
		bool menuOn;

		ofImage	allUserMasks, user1Mask, user2Mask, depthRangeMask;
        crImagePlus skin;
		ofxCvGrayscaleImage		blurImage;

		ParticleManager particleSystem;

		ofxOscSender sender;
		ofxOscReceiver	receiver;

		imgpanel ImMove;
		imgpanel ImRotate;
		imgpanel ImCancel;
		imgpanel ImZoom;
		imgpanel ImZoom2pt;
		ofImage bg;
		int timer, idActive;
};

#endif
